<?php
class CMRPageShowSection extends CMRPage
{
	private $section;
	
	public function __construct($database, $section)
	{
		parent::__construct($database);
		$this->section = $section;
	}
	
	protected function getContentsDiv()
	{
		$category = new Hidden();
		$category->setName("Category");
		$html = $category->getHTML();
	
		$html .= "<div id=\"content\">\n";
		$html .= "<h1>".$this->section."</h1>\n";
		
		$html .= "<p style=\"text-align: center;\">\n";
		
		$html .= "<img id=\"ImgChoral\" width=\"130\" height=\"80\" ";
		if($this->section!='Choral')
		{
			$html .= "onMouseOver=\"OnMouseOverChoral();\" ";
			$html .= "onMouseOut=\"OnMouseOutChoral();\" ";
		}
		$html .= "onclick=\"OnClickChoral();\" ";
		$html .= "src=\"../Images/Choral";
		if($this->section!='Choral')$html .= 'A';
		$html .= ".png\" />&nbsp;&nbsp;&nbsp;\n";
		
		$html .= "<img id=\"ImgOrgan\" width=\"130\" height=\"80\" ";
		if($this->section!='Organ')
		{
			$html .= "onMouseOver=\"OnMouseOverOrgan();\" ";
			$html .= "onMouseOut=\"OnMouseOutOrgan();\" ";
		}
		$html .= "onclick=\"OnClickOrgan();\" ";
		$html .= "src=\"../Images/Organ";
		if($this->section!='Organ')$html .= 'A';
		$html .= ".png\" />&nbsp;&nbsp;&nbsp;\n";
		
		$html .= "<img id=\"ImgLiturgy\" width=\"130\" height=\"80\" ";
		if($this->section!='Liturgy')
		{
			$html .= "onMouseOver=\"OnMouseOverLiturgy();\" ";
			$html .= "onMouseOut=\"OnMouseOutLiturgy();\" ";
		}
		$html .= "onclick=\"OnClickLiturgy();\" ";
		$html .= "src=\"../Images/Liturgy";
		if($this->section!='Liturgy')$html .= 'A';
		$html .= ".png\" />&nbsp;&nbsp;&nbsp;\n";
		
		$html .= "<img id=\"ImgProfessional\" width=\"130\" height=\"80\" ";
		if($this->section!='Professional')
		{
			$html .= "onMouseOver=\"OnMouseOverProfessional();\" ";
			$html .= "onMouseOut=\"OnMouseOutProfessional();\" ";
		}
		$html .= "onclick=\"OnClickProfessional();\" ";
		$html .= "src=\"../Images/Professional";
		if($this->section!='Professional')$html .= 'A';
		$html .= ".png\" />&nbsp;&nbsp;&nbsp;\n";
		
		$html .= "</p>\n";
		
		
		
		$html .= "<p> This section contains the resources contained in the ".$this->section." section. Choose a category from the list below.</p>\n";
		
		$sql = "SELECT * FROM ".$this->section."CategoryNames ORDER BY Name ";
//		echo $sql."<br>\n";
		$this->Database->ExecuteSQL($sql);
		
		while($row = $this->Database->getRow())
		{
			// get number of resources in this category
			$copyDatabase = $this->Database->recopy();
			$catSQL =  "SELECT res.*,cat.* FROM Resources as res ";
			$catSQL .= "INNER JOIN ".$this->section."Categorys AS cat ON res.ResourceID=cat.ResourceID ";
			$catSQL .= "WHERE DeletedBy = '0' and StatusTypeID = '3' AND cat.".$this->section."CategoryNameID=".$row[$this->section.'CategoryNameID']." ";
			$catSQL .= "ORDER BY ResourceTitle";
//			echo $catSQL."<br>\n";
			$copyDatabase->ExecuteSQL($catSQL);
			$count = $copyDatabase->getNumRows();
			if ($count == 0 ) $count = "No";
			
			$html .= "<div id=\"ShowSectionName\">".$row['Name']."<br><small><small>(".$count." resources)</small></small></div>\n";
			$html .= "<div id=\"ShowSectionDescription\">".$row['Description']."</div>\n";
			$browseImageID = "BrowseButton".$this->section.$row[$this->section."CategoryNameID"];
			$html .= "<div onclick=\"Show".$this->section."Category(".$row[$this->section."CategoryNameID"].")\" id=\"ShowSectionGoto\"><img id=\"".$browseImageID."\" onMouseOver=\"OnMouseOverBrowse('".$browseImageID."');\" onMouseOut=\"OnMouseOutBrowse('".$browseImageID."');\" src=\"../Images/Browse.png\" /></div>\n";
			$html .= "<p class=\"floatstop\" />\n";
		}
				
		$html .= "</div>\n";
		return $html;
	}
	
}